package ar.com.tallerdos.smartdinner.activity;

import android.widget.Toast;
import ar.com.tallerdos.smartdinner.business.MesaBusiness;
import ar.com.tallerdos.smartdinner.model.Mesa;
import ar.com.tallerdos.smartdinner.sync.GenericAsyncTask;
import ar.com.tallerdos.smartdinner.sync.MesasAbiertasWSClient;

public class SeleccionarMesasActivity extends SeleccionMultipleActivity<Mesa> {

    
    public void onFinishLoading() {
	this.items = MesaBusiness.findMesasLibres();
	setUpAdapter();
    }
    
    @Override
    protected void onFinishCreate() {
	new GenericAsyncTask(new MesasAbiertasWSClient(this), this).execute();	
    }

    @Override
    protected Mesa getItemById(Integer id) {
	return MesaBusiness.findById(id);
    }

    @Override
    protected void cargarItems() {
	// TODO Auto-generated method stub
	
    }
    
    @Override
    protected boolean seleccionValida() {
	for (Boolean b : adapter.getItemsSeleccionados()) {
	    if (b) {
		return true;
	    }
	}
	Toast.makeText(getApplicationContext(),"Debe seleccionar al menos una mesa", Toast.LENGTH_SHORT).show();
	return false;
    }

}
